<%@page import="qingke.util.ProductionRandomNumbers"%>
<%@page import="java.util.HashSet"%>
<%@page import="qingke.mybatis.pojo.Product"%>
<%@page import="qingke.mybatis.pojo.Store"%>
<%@page import="java.util.List"%>
<%@page import="service.Impl.StoreServiceImpl"%>
<%@page import="service.StoreService"%>
<%@page import="org.springframework.beans.factory.annotation.Autowired"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页</title>

<link href="${pageContext.request.contextPath }/css/style.css"
	type="text/css" rel="stylesheet" />
<script src="${pageContext.request.contextPath }/js/jquery-1.8.3.min.js"></script>
<script src="${pageContext.request.contextPath }/js/menu.js"></script>
<style type="text/css">
.shouyetu {
	width: 1200px;
	height: 450;
	margin: 0 auto
}
</style>
<jsp:include page="top.jsp" />
<%
	List<Product> RecommendedProducts = null;
	Object productsObject = session.getAttribute("recommendedProducts");
	if (productsObject != null) {
		if (productsObject instanceof List) {
			RecommendedProducts = (List<Product>) productsObject;
		}
	}
%>
<%
	List<Store> boutiques = null;
	Object storesObject = session.getAttribute("boutiques");
	if (storesObject != null) {
		if (storesObject instanceof List) {
			boutiques = (List<Store>) storesObject;
		}
	}
%>

</head>

<body>
	<br />
	<!--banna-->
	<div class="shouyetu">
		<img src="image/shouyetu.jpg" />
	</div>

	<!--内容01-->
	<div class="xinwen">
		<h1>精品店铺</h1>
	</div>
	<div class="d-bg">
		<div class="main02">

			<%
				if (boutiques != null) {
					int[] number = ProductionRandomNumbers.getIntNumber(3, boutiques.size());
					for (int i = 0; i < number.length; i++) {
						Store store = boutiques.get(number[i]);
			%>
			<div class="main02-l">

				<a href="#"><img src="image/product1.jpg" /></a> <br />
				<h2><%=store.getStoreName()%></h2>
				<p>
					<%
						if (store.getStoreDescription() != null) {
					%>
					<%=store.getStoreDescription().getStoreDescription()%>
					<%
						} else {
					%>
					该店家没有添加对该店的描述
					<%
						}
					%>
				</p>
			</div>
			<%
				}
				} else {
			%>
			<jsp:forward page="" />
			<%
				}
			%>
		</div>
	</div>

	<!--内容02-->
	<div class="pa">

		<img src="image/preferredProducts.jpg" />
		<p>
			优质商品<br /> <span>Preferred products</span>
		</p>

	</div>
	<div class="main03">
		<ul>
			<%
				if (RecommendedProducts != null) {
					int[] number = ProductionRandomNumbers.getIntNumber(4, RecommendedProducts.size());
					for (int i = 0; i < number.length; i++) {
			%>
			<li><a href="#"><img src="image/detail.jpg" /></a><br /> <a
				href="#"><span><%=RecommendedProducts.get(number[i]).getProductName()%></span></a>
				<span><%=RecommendedProducts.get(number[i]).getProductPrice()%>
			</span>
				<button
					onclick="addToCart(<%=RecommendedProducts.get(number[i]).getId()%>)">加入购物车</button>
			</li>
			<%
				}
				}
			%>
		</ul>
	</div>
	<!--底部-->

	<div>
		<jsp:include page="foot.jsp" />
	</div>
</body>
</html>
